//
//  NSValue+ACExt.m
//  ACFramework
//
//  Created by caoyq on 2018/6/14.
//  Updated by caoyq on 2018/6/22.
//

#import "NSValue+ACExt.h"

@implementation NSValue (ACExt)

+ (int)ac_getRandomValueFrom: (int)from to: (int)to
{
    //+1 是为了包括右区间，由[from, to) 变成 [from, to]
    return (int)(from + (arc4random() % (to - from + 1)));
}

+ (NSArray *)ac_getRandomValueFrom: (int)from to: (int)to count: (int)count
{
    NSMutableArray *result = [NSMutableArray array];
    while (result.count < count) {
        int value = [self ac_getRandomValueFrom:from to:to];
        if (![result containsObject:@(value)]) {
            [result addObject:@(value)];
        }
    }
    return result;
}

@end
